/**************************************************************************************
 *  Copyright (c)  2010  Leszek Karcz.
 *  Permission is granted to copy, distribute and/or modify this document
 *  under the terms of the GNU Free Documentation License, Version 1.3
 *  or any later version published by the Free Software Foundation;
 *  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 *  A copy of the license is included in the section entitled "GNU
 *  Free Documentation License". 
 **************************************************************************************/
package data;

/**************************************************************************************
 * Author(s): Leszek Karcz
 * This class contains per player visibility data for an individual "cell" on the map
 **************************************************************************************/
public class ViewTile {
	private int tickRefreshed;
	private boolean terrainDiscovered;
	private boolean resourceDiscovered;
	private String lastSeenStructure;
	private String StructureOwner;
	private String StructureHealthPercentage;
	private String lastSeenItem;
	private String[] lastSeenResourceImages;
	private String[] lastSeenResources;
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * ViewTile constructor
	 **************************************************************************************/
	public ViewTile()
	{
		this.tickRefreshed=-1;
		this.terrainDiscovered=false;
		this.resourceDiscovered=false;
		this.lastSeenStructure="";
		this.StructureHealthPercentage="";
		this.StructureOwner="";
		this.lastSeenItem="";		
		this.lastSeenResourceImages=new String[]{"","",""};
		this.lastSeenResources=new String[]{"","",""};		
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns:
	 * -whether the tile has been discovered
	 * -whether the resources had been discovered
	 * -whether the tile is currently visible
	 **************************************************************************************/
	public boolean[] getVisibilityStatus(int tick)
	{
		boolean[] status=new boolean[3];
		status[0]=this.terrainDiscovered;
		status[1]=this.resourceDiscovered;
		status[2]=(tick==this.tickRefreshed);
		return status;
	}	
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Discovers a tile and updates it's "last viewed" status and data
	 **************************************************************************************/
	public void refreshTile(int tick, String structure, int structureOwnerID, int structureHealthPercentage, String item, String[] lastSeenResourceImages, String[] lastSeenResources, boolean prospectMode)
	{
		this.terrainDiscovered=true;
		if(prospectMode)
		{
			this.resourceDiscovered=true;
		}
		this.tickRefreshed=tick;
		this.lastSeenStructure=structure;
		this.StructureOwner=structureOwnerID+"";
		this.StructureHealthPercentage=structureHealthPercentage+"";	
		this.lastSeenItem=item;
		this.lastSeenResourceImages=lastSeenResourceImages;
		this.lastSeenResources=lastSeenResources;	
	}	
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns image file for last seen structure
	 **************************************************************************************/
	public String[] getStructureData()
	{
		return new String[]{this.lastSeenStructure,this.StructureOwner+"",this.StructureHealthPercentage+""};
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns last seen resource images
	 **************************************************************************************/
	public String[] getResourceImages()
	{
		return this.lastSeenResourceImages;
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns last seen resource amounts
	 **************************************************************************************/
	public String[] getResourceData()
	{
		return this.lastSeenResources;
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz
	 * Returns last seen Item
	 **************************************************************************************/
	public String getTopItemData()
	{
		return this.lastSeenItem;
	}	
}
